package Servlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import Dao.StuDao;
import ppl.People;

@WebServlet(name = "demo3.Servlet.dataServlet", urlPatterns = "/demo3.Servlet.dataServlet")

public class dataServlet extends HttpServlet {

	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		List<People> peolist = new ArrayList<People>();
		StuDao stuDao = new StuDao();
		peolist = stuDao.getAll();

		if (null != peolist) {
			request.setAttribute("list", peolist);
			System.out.println("准备转发");
			request.getRequestDispatcher("/test3/jdbc.jsp").forward(request, response);
		}

	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		doGet(request, response);
	}

}
